package com.xvyy.tingshu.album.api;


import com.xvyy.tingshu.album.service.FileUploadService;
import com.xvyy.tingshu.common.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@Tag(name = "上传管理接口")
@RestController
@RequestMapping("api/album")
public class FileUploadApiController {

    @Autowired
    private FileUploadService fileUploadService;

    // Request URL: http://192.168.217.1:8500/api/album/fileUpload
    @PostMapping("/fileUpload")
    @Operation(summary = "文件上传")
    public Result<String> fileUpload(MultipartFile file) {

        String picUrl = fileUploadService.fileUpload(file);
        return Result.ok(picUrl);
    }


    //http://192.168.217.1:8500/api/album/trackInfo/uploadTrack
    @Operation(summary = "上传曲目")
    @PostMapping("/trackInfo/uploadTrack")
    public Result<Map<String, Object>> uploadTrack(MultipartFile file) {
        Map<String, Object> trackMap = fileUploadService.uploadTrack(file);
        return Result.ok(trackMap);
    }
}
